package com.java.tutorials.jdk7.fileoperation;

import com.java.tutorials.Constants;

import java.io.InputStream;
import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;

/**
 * Created by xuzhike on 2016/1/25.
 * http://www.java2s.com/Code/Java/JDK-7/CopyingfromanInputStream.htm
 * Copying from an Input Stream
 */
public class CopyingfromanInputStream {
    public static void main(String[] args) throws Exception {
        Path newFile = FileSystems.getDefault().getPath(Constants.TEST_PATH+"h3.html");
        URI url = URI.create("http://www.java2s.com/Code/Java/JDK-7/CatalogJDK-7.htm");
        InputStream inputStream = url.toURL().openStream();
        Files.copy(inputStream, newFile);
        System.out.println("Site copied successfully!");

    }
}
